package itesm.coler.data;

import java.sql.SQLException;
import java.util.ArrayList;

import itesm.coler.models.Course;

public interface CourseDAO {

	/**
     * Returns the course from the database matching the given id, otherwise null.
     * @param courseId: The id of the course to be returned.
     * @return The course from the database matching the given id, otherwise null.
     * @throws DAOException If something fails at database level.
     */
    public Course findCourseById(String courseId) throws DAOException;
    
    /**
     * Returns a list of all courses from the database ordered by course ID. The list is never null and
     * is empty when the database does not contain any course.
     * @return A list of all courses from the database ordered by course ID.
     * @throws DAOException If something fails at database level.
     */
	public ArrayList<Course> findAll() throws DAOException, SQLException;
	
	  /**
     * Returns a list of all courses from the database given by a professor ordered by course ID. The list is never null and
     * is empty when the database does not contain any course.
     * @param userId: The professor userId of the courses searched.
     * @return A list of all courses from the database ordered by course ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<Course> findAllByProfessor(String userId) throws DAOException;
    
	  /**
     * Returns a list of all courses from the database taken by a student ordered by course ID. The list is never null and
     * is empty when the database does not contain any course.
     * @param userId: The student userId of the courses searched.
     * @return A list of all courses from the database ordered by course ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<Course> findAllByStudent(String userId) throws DAOException;
 
    /**
     * Create the given course in the database. The courseid must be unique, otherwise it will throw
     * IllegalArgumentException.  
     * @param course The course to be created in the database.
     * @throws IllegalArgumentException If the courseid exists
     * @throws DAOException If something fails at database level.
     */
	  public int insertCourse(Course course) throws IllegalArgumentException, DAOException;
	  
	  /**
	     * Update the given course in the database. The courseid must not be null, otherwise it will throw
	     * IllegalArgumentException.
	     * @param course The user to be updated in the database.
	     * @throws IllegalArgumentException If the courseid is null.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateCourse(Course course) throws DAOException;
	  
	  /**
	     * Delete the given course from the database. 
	     * @param course The course to be deleted from the database.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean deleteCourse(String courseid) throws DAOException;
	  
	  /**
	     * Change the course's active status
	     * @param courseid The courseid which is to be checked in the database.
	     * @param status The active status: 1 active, 0 not active
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateCourseActiveStatus(String courseid, boolean status) throws DAOException;

}